package com.dingwen.treasure.kettle.base.convert.jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.dingwen.treasure.kettle.base.enums.BaseEnum;
import com.dingwen.treasure.kettle.constant.SuppressWarningConstant;

import java.io.IOException;

/**
 * 　AbstractEnumSerializer
 * 　@author dingwen
 * 　@date 2022/6/15
 */
@SuppressWarnings(SuppressWarningConstant.ALL)
public class BaseEnumSerializer<T extends BaseEnum> extends JsonSerializer<T> {


    /**
     * 实例
     */
    public static final BaseEnumSerializer INSTANCE = new BaseEnumSerializer();

    private BaseEnumSerializer() {
    }

    @Override
    public void serialize(T t, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeObject(t.getDescription());
    }
}
